package com.yic.module.device.dal.mysql.fault;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.device.dal.dataobject.fault.FaultDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.device.controller.admin.fault.vo.*;

/**
 * 设备报修 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface FaultMapper extends BaseMapperX<FaultDO> {

    default PageResult<FaultDO> selectPage(FaultPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FaultDO>()
                .likeIfPresent(FaultDO::getCode, reqVO.getCode())
                .eqIfPresent(FaultDO::getEmergent, reqVO.getEmergent())
                .betweenIfPresent(FaultDO::getFaultTime, reqVO.getFaultTime())
                .eqIfPresent(FaultDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(FaultDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(FaultDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(FaultDO::getCenterId, reqVO.getCenterId())
                .eqIfPresent(FaultDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(FaultDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FaultDO::getId));
    }

    default List<FaultDO> selectList(FaultExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FaultDO>()
                .likeIfPresent(FaultDO::getCode, reqVO.getCode())
                .eqIfPresent(FaultDO::getEmergent, reqVO.getEmergent())
                .betweenIfPresent(FaultDO::getFaultTime, reqVO.getFaultTime())
                .eqIfPresent(FaultDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(FaultDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(FaultDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(FaultDO::getCenterId, reqVO.getCenterId())
                .eqIfPresent(FaultDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(FaultDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FaultDO::getId));
    }

    default FaultDO selectByCode(String code) {
        return selectOne(new LambdaQueryWrapperX<FaultDO>()
                .eq(FaultDO::getCode, code));
    }
}
